package club.babyf.lbs.autoconfigure;

import club.babyf.lbs.config.LbsProperties;
import club.babyf.lbs.service.amap.AMapLbsProperties;
import club.babyf.lbs.service.amap.AMapLbsService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * LbsAutoConfiguration.
 *
 * @author zhanglei.
 * @date 2025/1/10 15:53.
 * @description 基于位置服务自动装配.
 */
@AutoConfiguration
@EnableConfigurationProperties(LbsProperties.class)
public class LbsAutoConfiguration {

    @AutoConfiguration
    @ConditionalOnProperty(prefix = "lbs", name = "provider", havingValue = "A_MAP")
    @EnableConfigurationProperties(AMapLbsProperties.class)
    public static class AMapConfig {

        @Bean
        @ConditionalOnMissingBean(AMapLbsService.class)
        public AMapLbsService aMapLbsService(AMapLbsProperties aMapLbsProperties) {
            return new AMapLbsService(aMapLbsProperties);
        }

    }

}
